<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>订单支付_{$web_name}</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="Keywords" content="订单支付" />
		<meta name="Description" content="订单支付" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1" />
		<meta name="format-detection" content="telephone=no">
		<tc_include file="Public:head" />
		<link rel="stylesheet" type="text/css" href="__TMPL__Home/Cart/css/cart.css" />
		<link rel="stylesheet" type="text/css" href="__TMPL__Home/Pay/Css/choose.css" />
	</head>

	<body>
		<tc_include file="Public:nav" />
		<div class="w990" id="content" style="background: none;">
			<div class="content">
				<div class="cart-step">
					<ul>
						<li class="cart1"><i></i>购物车</li>
						<li class="cart2"><i></i>确认订单</li>
						<li class="cart3"><i></i>付款</li>
						<li class="cart4"><i></i>支付成功</li>
					</ul>
				</div>

				<div class="js-main container order border border-gray-white text-default">
					<div class="order-info bg-gray-white padding-small-top padding-small-bottom padding-large-left padding-large-right border-bottom">
						<p>
							支付流水号： <span class="text-sub">{$_GET['order_cn']}</span>
						</p>
						<p>
							支付人：<span class="text-sub">{$name}</span>
						</p>
						<p>
							应付订单总额：<span class="text-mix">￥{:number_format($count_price,2)}</span>
						</p>
						<p class="text-sub" style="color: #333;">请您在<span class="font-red j_orderTime" style="color: #d93600;"></span>内完成支付，否则订单会被自动关闭。</p>
					</div>
					<div class="padding-small order-container">
						<div class="tip-title m-l-15 m-r-15 pays">
							<span class="padding-large-left">支付方式</span>
							<div class="border border-mix"></div>
						</div>
						<div class="pay-way item-checked margin padding clearfix pays js-select-pay">
							<php>if($wchat['wpay_is_use']){</php>
								<div class="item" data-pay="wchat">
									<i></i>
									<a class="pic-center border-none" href="javascript:;">
										<img src="__TMPL__Home/Pay/image/wechat_qr.png">
									</a>
								</div>
							<php>}</php>
							<php>if($alipay['alipay_is_use']){</php>
								<div class="item" data-pay="alipay">
									<i></i>
									<a class="pic-center border-none" href="javascript:;">
										<img src="__TMPL__Home/Pay/image/alipay.png">
									</a>
								</div>
							<php>}</php>
						</div>
						<div class="text-center">
							<a class="cart-btn text-default disabled" id="pay" href="javascript:;">立即支付</a>
						</div>
					</div>
				</div>

			</div>
		</div>
		<article class="mask-layer-dialog">
			<header>
				<i>x</i>
			</header>
			<div class="mask-warning-img">
				<img src="__TMPL__Home/Pay/image/pay_masklayer_warning.png" />
			</div>
			<div class="mask-content">
				<h3>请您在新打开的页面上完成付款操作。</h3>
				<p>付款完成前，请不要关闭此窗口。<br/>完成付款后请根据您的情况点击下面的按钮</p>
				<button>已完成付款，查看我的会员中心</button>
			</div>
		</article>
		<input type="hidden" value="{:date('Y-m-d H:i:s',$time)}" id="create_time" />
		<php>if($tuanselect>0){</php>
		<input type="hidden" value="3" id="buy_close_time" />
		<php>}else{</php>
		<input type="hidden" value="86400" id="buy_close_time" />
		<php>}</php>
		<div style="clear: both;"></div>
		<tc_include file="Public:footer" />
		<script>
			$(function() {
				setFooterStyle();
				//设置时间倒计时
				countdown();
				interval = setInterval("countdown()", 1000);
				$(".js-select-pay>div").click(function() {
					$(".js-select-pay>div").removeClass("selected");
					$(this).addClass("selected");
					$("#pay").removeClass("disabled");
				})

				//去支付
				$("#pay").click(function() {
					if($('.js-select-pay>.selected').attr("data-pay") != null) {

						switch($('.js-select-pay>.selected').attr("data-pay")) {
							case "wchat":
								var url = "{:U('pay/wchatpay',array('order_cn'=>$_GET['order_cn']))}";
								break;
							case "alipay":
								//跳转到支付宝
								var url = "{:U('pay/alipay',array('order_cn'=>$_GET['order_cn']))}";
								break;
						}
						window.open(url);
						$(".mask-layer-dialog").fadeIn(300);
						$(".mask-layer").fadeIn(300);
					}
				})

				//关闭弹出层
				$(".mask-layer-dialog header i").click(function() {
					$(".mask-layer-dialog").fadeOut(300);
					$(".mask-layer").fadeOut(300);
				})

				$(".mask-content button").click(function() {
					window.location.href = "{:U('user/order_info',array('order'=>$_GET['order_cn']))}";
				})
			})
			var interval = null;
			var fw_date='{:date("Y-m-d H:i:s", time())}';
			var flag=true;
			function countdown() {
				var date = new Date($("#create_time").val().replace(/\-/g, "\/")); //订单创建时间
				var buy_close_time = parseFloat($("#buy_close_time").val()) * 60 * 1000; //订单关闭时间
				var timestamp2 = new Date(fw_date.replace(/\-/g, "\/"));; //当前时间
				var timestamp2 = timestamp2.getTime();
				var timestamp2 = timestamp2 / 1000+1;
				fw_date=new Date(parseInt(timestamp2) * 1000).Format("yyyy-MM-dd hh:mm:ss");
				var date_now = new Date(fw_date.replace(/\-/g, "\/"));; //当前时间
				var end_time = date.getTime() + buy_close_time; //结束时间毫秒数
				var lag = (end_time - date_now.getTime()) / 1000; //当前时间和结束时间之间的秒数
				if(lag > 0) {
					var hour = Math.floor((lag / 3600) % 24);
					var minute = Math.floor((lag / 60) % 60);
					var second = Math.floor(lag % 60);
					if(hour == 0 && second == 0 && minute == 0) {
						clearInterval(interval);
						window.location.href = "{:U('user/order')}";
					}
					if(second < 10) {
						second = "0" + second;
					}
					if(minute < 10) {
						minute = "0" + minute;
					}
					if(hour < 10) {
						hour = "0" + hour;
					}
					$(".j_orderTime").text(hour + ":" + minute + ":" + second);
				}
			}
			Date.prototype.Format = function (fmt) { //author: meizz   
		        var o = {  
		            "M+": this.getMonth() + 1, //月份   
		            "d+": this.getDate(), //日   
		            "h+": this.getHours(), //小时   
		            "m+": this.getMinutes(), //分   
		            "s+": this.getSeconds(), //秒   
		            "q+": Math.floor((this.getMonth() + 3) / 3), //季度   
		            "S": this.getMilliseconds() //毫秒   
		        };  
		        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));  
		        for (var k in o)  
		        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));  
		        return fmt;  
		    } 
			function setFooterStyle() {

				var main_height = $(".js-main").height() + 220;
				var window_height = $(window).height();
				if(main_height > window_height) {
					$('.footer').css("position", "relative");
				} else {
					$('.footer').css("position", "fixed");
				}
			}

			window.onresize = function() {
				setFooterStyle();
			}
		</script>
		
		
	</body>

</html>